/**
 * Created by CN-xin on 2018/10/22.
 */

mini.parse();
var grid = mini.get("datagrid1");
var url = bootPATH + "../frame/frame1/pages/activiti/";      //路径前缀

mini_debugger = false;
//页面初始化
$(listDetai);
//数据请求
function listDetai(){
    $.ajax({
        url: ajaxUrl+ "/process/modelList.do",
        type:"POST",
        data:{
            rows:5
        },
        success : function(data){
            console.log(data);
            var activitiList = data.list;
            grid.setData(activitiList);
        },
        error : function(data){
            console.log("失败")
        }
    })
}

//查看流程图
function sercherPng() {
    var row = grid.getSelecteds();
    if(row.length == 1){
    	if(row==null){
    	      mini.alert("请选择已部署流程！！！")
    	    }else{
    	    	console.log(row);
	    	    var deploymentId=row[0].deploymentId
	    	    var diagramResourceName=row[0].diagramResourceName
	    	    fileUrl = "http://localhost:8080/DSMP/process/showView.do?deploymentId="+deploymentId+"&diagramResourceName="+diagramResourceName;
	    	    images = document.getElementById("imgs")
	    	    images.src = fileUrl;
	    	    var process = document.getElementById("process");
	    	    process.style.display = "block";
    	    }
    }else{
    	mini.alert('请选择一条查看');
    }
}
function close(){
    images = document.getElementById("imgs")
    images.src = '';
    var process = document.getElementById("process");
    console.log(process);
    process.style.display = "none";
}

function Toadd(){
    var table = document.getElementById("add")
    table.style.display = "block";
}


function out(){
    var table = document.getElementById("add")
    table.style.display = "none";
}

function ToModel(){
    console.log("编辑流程")
    var row = grid.getSelected();
    var deploymentId=row.deploymentId
    console.log(row)
    console.log(deploymentId)
    window.location.href = "http://localhost:8080/bpm/process/edit.do?processId="+deploymentId;
}
//删除
function remove(){
    var row = grid.getSelected();
    if(row==null){
        mini.alert("请选择要删除的流程实例！！！")
    }else{
        var deploymentId=row.deploymentId
        if(confirm("是否删除")){
            $.ajax({
                url:ajaxUrl+"/process/removeProcess.do?deploymentId="+deploymentId,
                type:"POST",
                success:function(data){
                    listDetai();
                },
                error:function(data){
                    listDetai();
                }
            })
        }
    }
}
//刷新
function refresh(){
	listDetai();
}